<template>
  <el-dialog v-model="visible" :title="title" :close-on-click-modal="false" :close-on-press-escape="false">
    <el-form :model="dataForm" :rules="dataRule" ref="dataFormRef"  label-width="120px">
      <el-form-item label="id" prop="id" v-if="false">
        <el-input v-model="dataForm.id" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="学校" prop="schoolName">
        <el-input v-model="dataForm.schoolName" placeholder="名称"></el-input>
      </el-form-item>

    </el-form>
    <template v-slot:footer>
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmitHandle()">提交</el-button>
    </template>
  </el-dialog>
</template>

<script lang="ts">
import { defineComponent, reactive } from "vue";
import baseService from "@/service/baseService";
import {getCache, setCache} from "@/utils/cache";
import router from "@/router";
import {ElMessage} from "element-plus";
export default defineComponent({
  setup() {
    return reactive({
      visible: true,
      title:"修改名称",
      dataForm: {
        id: "",
        schoolName: ""

      }
    });
  },
  computed: {
    dataRule() {
      return {
      };
    }
  },
  methods: {
    init(row:any) {
      this.visible = true;
      this.dataForm.id = row.id
      if(row.id){
        this.title ="修改学校名称"}
      else{
        this.title ="添加学校";
      }
      this.dataForm.schoolName = row.schoolName;
      this.$nextTick(() => {
        this.visible = true;
      });
    },
    // 获取信息
    getInfo() {

    },
    // 表单提交
    dataFormSubmitHandle() {
      baseService
          .post("/fii/front/school/addOrUpdate",{id:this.dataForm.id,schoolName:this.dataForm.schoolName})
          .then((res) =>
              {
                if (res.code === 0) {
                  this.visible=false;
                  this.$emit("refreshDataList");
                } else {
                  ElMessage.error(res.msg);
                }
              }
          );
    }
  }
});
</script>